package mysql

import "gorm.io/gorm"

type Orders struct {
	gorm.Model
	UserID      int     `gorm:"type:int(10);not null;comment:用户id"`
	GoodsID     int     `gorm:"type:int(10);not null;comment:商品id"`
	OrderTitle  string  `gorm:"type:varchar(20);not null;comment:订单标题"`
	OrderCover  string  `gorm:"type:varchar(200);not null;comment:订单封面"`
	OrderAmount float64 `gorm:"type:decimal(10,2);not null;comment:订单金额"`
	OrderStock  int     `gorm:"type:int(10);not null;comment:订单数量"`
	OrderState  int     `gorm:"type:int(10);not null;comment:订单状态"`
	OrderSn     string  `gorm:"type:varchar(200);not null;comment:订单编号"`
	Payment     int     `gorm:"type:int(10);not null;comment:支付类型"`
}

func (o *Orders) Create() error {
	return DB.Debug().Create(&o).Error
}
func (o *Orders) OrderList() (list []*Orders, err error) {
	err = DB.Find(&list).Error
	return
}
